{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>待处理订单</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">   

                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('complete')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="key" value="{$val}" placeholder="输入需查询的订单号/用户ID/手机号" />
                                <span class="input-group-btn"> 
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button> 
                                </span>
                            </div>
                        </div>
                    </form>                         
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th width="4%">ID</th>
                                <th width="4%">账号</th>
                                <th width="9%">昵称</th>
                                <th width="5%">运营商</th>
                                <th width="9%">手机号</th>
                                <th width="5%">金额</th>
                                <th width="5%">付款金额</th>
                                <th width="5%">用户类型</th>
                                <th width="5%">付款方式</th>
                                <th width="9%">订单号</th>
                                <th width="10%">创建时间</th>
                                <th width="6%">状态</th>
                                <th width="6%">操作</th>
                            </tr>
                        </thead>
                        <script id="list-template" type="text/html">
                            {{# for(var i=0;i<d.length;i++){  }}
                            <tr class="long-td">
                                <td>{{d[i].id}}</td>
                                <td>{{d[i].uid}}</td>
                                <td>{{d[i].nick}}</td>
                                <td>
                                    {{# if(d[i].cate_id==1){ }}
                                    metfone
                                    {{# }else if(d[i].cate_id==2){ }}
                                    cellcard
                                    {{# }else{ }}
                                    Smart
                                    {{# } }}
                                </td>
                                <td>
                                    {{d[i].phone}}
                                </td>
                                <td>{{d[i].order_money}}</td>
                                <td>
                                    {{d[i].reality_money}}
                                </td>
                                <td>
                                    {{# if(d[i].uid_cate_id==1){ }}
                                   普通用户
                                    {{# }else if(d[i].uid_cate_id==2){ }}
                                    代理会员
                                    {{# } }}
                                </td>
                                <td>
                                    {{# if(d[i].paytype==1){ }}
                                    在线支付
                                    {{# }else if(d[i].paytype==2){ }}
                                    余额支付
                                    {{# } }}

                                </td>
                                <td>{{d[i].out_trade_no}}</td>
                                <td>{{d[i].create_time}}</td>
                                <td>
                                    {{# if(d[i].ord_status==0){ }}
                                    待处理
                                    {{# }else if(d[i].ord_status==1){ }}
                                    已处理
                                    {{# }else{ }}
                                    失败
                                    {{# } }}
                                </td>

                                <td>                                  
                                    <a href="javascript:;" onclick="edit({{d[i].id}})" class="btn btn-primary btn-outline btn-xs">
                                        <i class="fa fa-paste"></i> 编辑</a>

                                </td>
                            </tr>
                            {{# } }}
                        </script>
                        <tbody id="list-content"></tbody>
                    </table>
                    <div id="AjaxPage" style=" text-align: right;"></div>
                    <div id="allpage" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

<!-- 加载动画 -->
<div class="spiner-example">
    <div class="sk-spinner sk-spinner-three-bounce">
        <div class="sk-bounce1"></div>
        <div class="sk-bounce2"></div>
        <div class="sk-bounce3"></div>
    </div>
</div>
<div class="modal  fade" id="myModal" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h3 class="modal-title">处理订单</h3>
            </div>
            <form class="form-horizontal" name="add_rule" id="add_rule" method="post" action="">
                <div class="ibox-content">

                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">账号</label>
                        <div class="col-sm-8" id="zhanghao">
                        ###
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">订单号</label>
                        <div class="col-sm-8" id="dingdanhao">
                         ###
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">运营商</label>
                        <div class="col-sm-8" id="yongyingshang">
                         ###
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">手机号</label>
                        <div class="col-sm-8" id="shoujihao">
                         ###
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">金额</label>
                        <div class="col-sm-8" id="jine">
                        ###
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" onclick="chongzhiok();" class="btn btn-primary"><i class="fa fa-save"></i> 充值完成</button>
                    <button type="button" onclick="chongzhituikuai();" class="btn btn-warning"><i class="fa fa-save"></i> 退款</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">
   
    //laypage分页
    Ajaxpage();
    function Ajaxpage(curr){
        var key=$('#key').val();
        $.getJSON('{:url("pending")}', {page: curr || 1,key:key}, function(data){
            $(".spiner-example").css('display','none'); //数据加载完关闭动画 
            if(data==''){
                $("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
            }else{
                var tpl = document.getElementById('list-template').innerHTML;
                laytpl(tpl).render(data, function(html){
                    document.getElementById('list-content').innerHTML = html;
                });
                laypage({
                    cont: $('#AjaxPage'),//容器。值支持id名、原生dom对象，jquery对象,
                    pages:'{$allpage}',//总页数
                    skip: true,//是否开启跳页
                    skin: '#1AB5B7',//分页组件颜色
                    curr: curr || 1,
                    groups: 3,//连续显示分页数
                    jump: function(obj, first){
                        if(!first){
                            Ajaxpage(obj.curr)
                        }
                        $('#allpage').html('第'+ obj.curr +'页，共'+ obj.pages +'页');
                    }
                });
            }
        });
    }
var curr_id=0;
//编辑会员
function edit(id){
   // location.href = './edit_member/id/'+id+'.html';
    curr_id=id;
    $.get('{:URL("getinfo")}',{id:id}, function (data) {
        if(data.code ==1 ){
            var d=data.data;
            $('#zhanghao').html(d.uid);
            $('#dingdanhao').html(d.out_trade_no);
            $('#yongyingshang').html(d.cate_id);
            $('#shoujihao').html(d.phone);
           $('#jine').html(d.order_money);
            $("#myModal").modal("show");
        }
    });
}
    function chongzhiok(){
        $.post('{:URL("chongzhiok")}',{id:curr_id}, function (data) {
            if(data.code == 1){
                lunhui.success("处理成功",document.location.href);
                $("#myModal").modal("hide");
            }else{
                lunhui.error(data.info);
            }
        });
    }
    function chongzhituikuai(){
        $.post('{:URL("chongzhituikuai")}',{id:curr_id}, function (data) {
            if(data.code == 1){
                lunhui.success("退款成功",document.location.href);
                $("#myModal").modal("hide");
            }else{
                lunhui.error(data.info);
            }
        });
    }


</script>
</body>
</html>